<?php

/**
* This is the model class for table "TB_QTC_MENU".
*
* The followings are the available columns in table 'TB_QTC_MENU':
    * @property string $MENU_CODE
    * @property string $PARENT_MENU_CODE
    * @property string $MENU_NAME
    * @property string $MENU_ENG_NAME
    * @property string $KEYWORDS
    * @property integer $SORT_ORDER
    * @property string $USE_YN
    * @property string $MENU_SLUG_ENG
    * @property string $MENU_SLUG
    * @property string $FIRST_REG_DT
    * @property string $FIRST_REG_USER
    * @property string $FIRST_REG_IP
    * @property string $LAST_UPD_DT
    * @property string $LAST_UPD_USER
    * @property string $LAST_REG_IP
*/
class Menu extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'TB_QTC_MENU';
}

/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
    array('KEYWORDS, SORT_ORDER, MENU_SLUG_ENG, MENU_SLUG, FIRST_REG_DT, LAST_UPD_DT', 'required'),
    array('SORT_ORDER', 'numerical', 'integerOnly'=>true),
    array('PARENT_MENU_CODE', 'length', 'max'=>11),
    array('MENU_NAME, MENU_ENG_NAME, FIRST_REG_USER, FIRST_REG_IP, LAST_UPD_USER, LAST_REG_IP', 'length', 'max'=>50),
    array('KEYWORDS, MENU_SLUG_ENG, MENU_SLUG', 'length', 'max'=>100),
    array('USE_YN', 'length', 'max'=>1),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('MENU_CODE, PARENT_MENU_CODE, MENU_NAME, MENU_ENG_NAME, KEYWORDS, SORT_ORDER, USE_YN, MENU_SLUG_ENG, MENU_SLUG, FIRST_REG_DT, FIRST_REG_USER, FIRST_REG_IP, LAST_UPD_DT, LAST_UPD_USER, LAST_REG_IP', 'safe', 'on'=>'search'),
);
}

/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
    return array(
        'Product' => array(self::HAS_MANY, 'Product', 'MENU_CODE', 'with' => "GroupFile"),
    );
}

/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
    'MENU_CODE' => 'MENU CODE',
    'PARENT_MENU_CODE' => 'PARENT MENU CODE',
    'MENU_NAME' => 'MENU NAME',
    'MENU_ENG_NAME' => 'MENU ENGLISH NAME',
    'KEYWORDS' => 'KEYWORDS',
    'SORT_ORDER' => 'SORT ORDER',
    'USE_YN' => 'USE YN',
    'MENU_SLUG_ENG' => 'Menu Slug Eng',
    'MENU_SLUG' => 'Menu Slug',
    'FIRST_REG_DT' => 'FIRST REGISTER DATE',
    'FIRST_REG_USER' => 'FIRST REGISTER USER',
    'FIRST_REG_IP' => 'First Reg Ip',
    'LAST_UPD_DT' => 'LAST UPDATE DATE',
    'LAST_UPD_USER' => 'LAST UPDATE USER',
    'LAST_REG_IP' => 'Last Reg Ip',
);
}

/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.

$criteria=new CDbCriteria;

		$criteria->compare('MENU_CODE',$this->MENU_CODE,true);
		$criteria->compare('PARENT_MENU_CODE',$this->PARENT_MENU_CODE,true);
		$criteria->compare('MENU_NAME',$this->MENU_NAME,true);
		$criteria->compare('MENU_ENG_NAME',$this->MENU_ENG_NAME,true);
		$criteria->compare('KEYWORDS',$this->KEYWORDS,true);
		$criteria->compare('SORT_ORDER',$this->SORT_ORDER);
		$criteria->compare('USE_YN',$this->USE_YN,true);
		$criteria->compare('MENU_SLUG_ENG',$this->MENU_SLUG_ENG,true);
		$criteria->compare('MENU_SLUG',$this->MENU_SLUG,true);
		$criteria->compare('FIRST_REG_DT',$this->FIRST_REG_DT,true);
		$criteria->compare('FIRST_REG_USER',$this->FIRST_REG_USER,true);
		$criteria->compare('FIRST_REG_IP',$this->FIRST_REG_IP,true);
		$criteria->compare('LAST_UPD_DT',$this->LAST_UPD_DT,true);
		$criteria->compare('LAST_UPD_USER',$this->LAST_UPD_USER,true);
		$criteria->compare('LAST_REG_IP',$this->LAST_REG_IP,true);

return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}

/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Menu the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
